package com.kartoshka.painters 
{
	import flash.display.Graphics;
	import com.kartoshka.interfaces.IPainter;

	/**
	 * @author Alexander Zats, 2009
	 */
	public class BackgroundSolidPainer extends NullPainter implements IPainter 
	{
		protected var _color : uint;
		protected var _alpha : Number;

		public function BackgroundSolidPainer( color : uint = 0x808080, alpha : Number = 1, cornerRadius : Number = 0 )
		{
			super( );
			_color = color;
			_alpha = alpha;
			_cornerRadius = cornerRadius;
		}

		override public function draw( graphics : Graphics, width : Number, height : Number ) : void
		{
			graphics.beginFill( _color, _alpha );
			_cornerRadius ? graphics.drawRoundRect( 0, 0, width, height, _cornerRadius, _cornerRadius) : graphics.drawRect( 0, 0, width, height );
			graphics.endFill();
		}

		public function set color( value : uint ) : void
		{
			if ( value > 0xFFFFFF ) value = 0xFFFFFF;
			_color = value;
		}
		
		public function get color() : uint
		{
			return _color;
		}
		
		public function set alpha( value : Number ) : void
		{
			if ( value > 1 ) value = 1;
			else if ( value < 0 ) value = 0;
			_alpha = value;
		}
		
		public function get alpha() : Number
		{
			return _alpha;
		}
	}
}
